//
//  OurselvesViewController.m
//  caishuitong
//
//  Created by qiysoft on 2017/4/24.
//  Copyright © 2017年 zhangxy. All rights reserved.
//

#import "OurselvesViewController.h"
#import "WWebViewController.h"

@interface OurselvesViewController ()

@property (weak, nonatomic) IBOutlet UILabel *lbVerson;

@end

@implementation OurselvesViewController

- (void)viewDidLoad {
   [super viewDidLoad];
    self.title = @"关于我们";
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
    _lbVerson.text = [NSString stringWithFormat:@"v%@",app_Version];
}

- (IBAction)btnClick:(UIButton *)sender {
    if (sender.tag == 1000) {

        [self requestInterfaceInfo:@"czzy"];
//        WWebViewController *webVc = [[WWebViewController alloc] init];
//        NSDictionary *parametersDict = @{@"mode":@"web",@"service":@"czzy",@"content":@{}};
////        NSString *strUrl = @"http://www.icdes.cn/sxhtjs/zstapp?params=";
//        NSString *strUrl = [NSString stringWithFormat:@"%@?params=",[WShareUtil getServerURL:nil]];
//        webVc.strUrl = [WShareUtil webUrlAppendingString:strUrl dic:parametersDict];
//        webVc.strTitle = @"操作指引";
//
//        webVc.shareTitle = @"操作指引";//分享标题
//        webVc.from = @"czzy";//来源
//
//        [self.navigationController pushViewController:webVc animated:YES];

    } else if (sender.tag == 1001) {

         [self requestInterfaceInfo:@"sjsm"];
//        WWebViewController *webVc = [[WWebViewController alloc] init];
//        NSDictionary *parametersDict = @{@"mode":@"web",@"service":@"sjsm",@"content":@{}};
////        NSString *strUrl = @"http://www.icdes.cn/sxhtjs/zstapp?params=";
//        NSString *strUrl = [NSString stringWithFormat:@"%@?params=",[WShareUtil getServerURL:nil]];
//        webVc.strUrl = [WShareUtil webUrlAppendingString:strUrl dic:parametersDict];
//        webVc.strTitle = @"升级说明";
//
//        webVc.shareTitle = @"升级说明";//分享标题
//        webVc.from = @"sjsm";//来源
//
//        [self.navigationController pushViewController:webVc animated:YES];

    }
}

- (void)requestInterfaceInfo:(NSString *)from {

    NSDictionary *parametersDict = @{@"mode":@"native",@"service":@"shareinfo",@"content":@{@"from":from,@"type":@"custom"}};
    NSString *secret = [NSString stringWithFormat:@"%@",[WHttpTool convertToJsonData:parametersDict]];
    NSDictionary *paramsDic = @{@"params":[CommonFunc encryptWithText:secret]};

    [WHttpTool POST:[WShareUtil getServerURL:nil] parameters:@{@"params":[CommonFunc encryptWithText:secret]} success:^(id responseObject) {
        WLog(@"------%@",responseObject);
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *JsonDic = [WHttpTool dictionaryWithJsonString:responseStr];
        NSString *messageStr = [JsonDic objectForKey:@"message"];
        NSString *successStr = [JsonDic objectForKey:@"success"];
        // 解密请求回的数据（字典）
        NSString *returnStr = [CommonFunc decryptWithText:messageStr];

        // json字符串转字典
        NSDictionary *returnDic = [WHttpTool dictionaryWithJsonString:returnStr];

        WWebViewController *webVc = [[WWebViewController alloc] init];
        webVc.from = from;//来源
        if ([successStr isEqualToString:@"true"]) {
            webVc.strUrl = returnDic[@"link"];
            webVc.strTitle = @"操作指引";
            webVc.shareTitle = returnDic[@"title"];//分享标题
        }

        [self.navigationController pushViewController:webVc animated:YES];

    } failure:^(NSError *error) {
        WLog(@"失败");
    } showProgress:NO];
}

@end
